/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package imageprocessing;

import com.Zhang.Suen.thinning.ThinningService;
import java.io.IOException;
import com.azon.face.detection.ImageDetection;
import com.azon.ip.utils.ImageReader;
import com.azon.ip.utils.ImageWriter;
import com.azon.left.hand.Guesser;
import com.azon.left.hand.MatrixConverter;
import com.azon.left.hand.ThinnedWetLeftHand;
import com.azon.left.hand.WetLeftHand;
import com.azon.left.hand.thinnedNumberGuesser;
import com.isip.transformation.Transformation;
import com.isip.transformation.difference.DifferenceFunction;
import java.awt.image.BufferedImage;

/**
 *
 * @author Ahmad Fauzan
 */
public class ImageProcessing {
    
    /**
     * @param args the command line arguments
     * @throws java.io.IOException
     */
    public static void main(String[] args) throws IOException {
        // TODO code application logic here
        String path = "image\\Time New Roman.jpg";
        
        /*
        WetLeftHand     wet         = new ThinnedWetLeftHand();
        Guesser         guesser     = new thinnedNumberGuesser();
        MatrixConverter converter   = new MatrixConverter();
        ThinningService thinner     = new ThinningService();
        Transformation  transform   = new DifferenceFunction();
        */
        
        //int[][] matrix_image            = ImageReader.ReadImageAsRGB(path);
        int[][] matrix_grayscale        = ImageReader.ReadImageAsGrayScale(path);
        /*
        int[][] matrix_blackandwhite    = converter.blackAndWhiteConverter(matrix_grayscale);
        int[][] thinned_matrix          = thinner.doZhangSuenThinning(converter.blackAndWhiteReverser(matrix_blackandwhite));
        int[][] reversed_matrix         = converter.blackAndWhiteReverser(thinned_matrix);
        int[][] reverted_matrix         = converter.blackAndWhiteReverter(reversed_matrix);
        
        String[]    chain_codes = wet.doWetLeftHand(reversed_matrix);
        
        int iteration = 0;
        for (String chain_code : chain_codes) {
            System.out.println("***********************************");
            System.out.println("Benda ke-" + (iteration + 1));
            guesser.printObjectProperty(chain_code);
            System.out.println(guesser.doGueess(chain_code));
            iteration++;
        }
        */
        
        
        
        
        //ImageDetection detect = new ImageDetection();
        
        //int[][] transformed_matrix = transform.doTransform(matrix_grayscale);
        //int[][] smoother_matrix = converter.smootherConverter(transformed_matrix);
        
        
        //int[][] marked_matrix    = detect.doMark(matrix_grayscale);
        
        //int[] border  = detect.doDetect(marked_matrix);
        
        //int[][] detected_matrix = detect.drawBox(border, matrix_image);
        
        printMatrix(matrix_grayscale);
        
        //BufferedImage new_img = ImageWriter.writeImageGrayScale(marked_matrix);
        //ImageWriter.WriteImage(new_img, "result2.jpg"); // */
        
    }

    public static void printMatrix(int[][] matrix) {
        for (int m = 0; m < matrix.length; m++) {
            for (int n = 0; n < matrix[0].length; n++) {
                System.out.print( matrix[m][n]+ " ");
            }
            System.out.println("");
        }
    }
}
